import logging

import pytest

from resource.pom.settings import Settings


class Test:
    app = Settings

    @pytest.mark.parametrize('setup_teardown', [app.bundle_name], indirect=True)
    def test(self, setup_teardown, device):
        logging.info('步骤1.点击设置应用')
        device.start_ability(self.app.bundle_name, self.app.ability_name)
        logging.info('预期结果1.进入设置界面')
        device.assert_current_window(self.app.window_name)

        logging.info('步骤2.点击隐私')
        device.click(*self.app.privacy_item)
        logging.info('预期结果2.进入隐私')
        device.refresh_layout()
        device.assert_text_exist('证书与凭据')

        logging.info('步骤3.点击证书与凭证')
        device.click_element(device.get_element_by_text('证书与凭据'))
        logging.info('预期结果3.进入证书与凭证')
        device.refresh_layout()
        device.assert_text_exist('CA证书')
        device.assert_text_exist('凭据列表')
        device.assert_text_exist('从存储设备安装')
        device.assert_text_exist('删除所有证书与凭据')

        logging.info('步骤4.点击凭证列表')
        device.click_element(device.get_element_by_text('凭据列表'))
        logging.info('预期结果4.正常进入凭证列表界面')
        device.refresh_layout()
        device.assert_text_exist('系统')
        device.assert_text_exist('用户')